//
//  NavigationBarElement.m
//  MenkNav
//
//  Created by Burn on 2019/6/25.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "NavigationBarElement.h"

@interface NavigationBarElement ()

@property(strong,nonatomic) UITextField *search;
@property(strong,nonatomic) UILabel *title;
@property(strong,nonatomic) UIButton  *button;

@end

@implementation NavigationBarElement

-(instancetype)initWithTitle:(NSString *)title{
    
    self.title = [[UILabel alloc]init];
    self.title.transform = MenkTransform;
    self.title.font = MenksoftQagan_mirror(14);
    self.title.text = title;
    self.title.numberOfLines = 0;
    self.backgroundColor = [UIColor redColor];
    
    self.title.frame = CGRectMake(0, 0, 5, SafeAreaTopHeight - SafeAreaValueHeight);
    [self.title sizeToFit];
    self.title.frame = CGRectMake(0, 0, self.title.frame.size.width, self.title.frame.size.height);
    if (self = [super initWithFrame:self.title.frame]) {
        [self addSubview:self.title];
    }
    return self;
}


-(instancetype)initWithSearch{
    
    
    UIView *rightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 35)];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_nav_search"]];
    imageView.contentMode = UIViewContentModeCenter;
    imageView.frame = CGRectMake(0, 0, 40, 35);
    [rightView addSubview:imageView];
    
    self.search = [[UITextField alloc]init];
    self.search.frame = CGRectMake(0, 0, SCREEN_WIDTH - 150, 35);
    self.search.borderStyle = UITextBorderStyleRoundedRect;
    self.search.tintColor = [UIColor orangeColor];
    self.search.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:.2];
    self.search.rightView = rightView;
    
    self.search.rightViewMode = UITextFieldViewModeAlways;
    if (self = [super initWithFrame:self.search.frame]) {
        [self addSubview:self.search];
    }
    return self;
}


- (instancetype)initWithRight{
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button.frame = CGRectMake(0, 0, 40, 40);
    self.button.backgroundColor = [UIColor redColor];
    if (self = [super initWithFrame:self.button.frame]) {
        [self addSubview:self.button];
    }
    return self;
}




-(instancetype)initWithOrdosTV{
    UIView *titleView = [[UIView alloc]init];
    UILabel *largeTitle = [[UILabel alloc]init];
    largeTitle.transform = CGAffineTransformScale(largeTitle.transform, -1, 1);
    largeTitle.transform =  CGAffineTransformRotate(largeTitle.transform, M_PI / 2);
    largeTitle.numberOfLines = 0;
    largeTitle.textColor = [UIColor colorWithRed:11 / 255.0 green:90 / 255.0 blue:132 / 255.0 alpha:1];
    largeTitle.font = HvrStudioChaganTig_M(18);
    largeTitle.textAlignment = NSTextAlignmentCenter;
    largeTitle.text = @"  \n\n\n\n";
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor colorWithRed:197 / 255.0 green:197 / 255.0 blue:197 / 255.0 alpha:1];
    [titleView addSubview:line];
    
    UILabel *smallTitleTop = [[UILabel alloc]init];
    smallTitleTop.textColor = [UIColor colorWithRed:11 / 255.0 green:90 / 255.0 blue:132 / 255.0 alpha:1];
    //    smallTitleTop.backgroundColor = [UIColor redColor];
    smallTitleTop.transform = CGAffineTransformScale(smallTitleTop.transform, -1, 1);
    smallTitleTop.transform =  CGAffineTransformRotate(smallTitleTop.transform, M_PI / 2);
    smallTitleTop.text = @"  \n\n \n\n  \n\n \n";
    smallTitleTop.numberOfLines = 0;
    smallTitleTop.font = HvrStudioChaganTig_M(13);
    
    UILabel *smallTitleBottom = [[UILabel alloc]init];
    smallTitleBottom.text = @"鄂尔多斯蒙古语广播电视网";
    smallTitleBottom.textColor = [UIColor colorWithRed:11 / 255.0 green:90 / 255.0 blue:132 / 255.0 alpha:1];
    smallTitleBottom.font = [UIFont systemFontOfSize:13];
    
    [titleView addSubview:largeTitle];
    [titleView addSubview:line];
    [titleView addSubview:smallTitleTop];
    [titleView addSubview:smallTitleBottom];
    
    largeTitle.frame = CGRectMake(0, 0, (([UIScreen mainScreen].bounds.size.width - 1) / 2) - 40, 40);
    line.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width - 90) * .5 , 0, 0.5, 40);
    smallTitleTop.frame = CGRectMake(CGRectGetMaxX(line.frame) + 10, 0, ([UIScreen mainScreen].bounds.size.width ) / 2 - 55, 29);
    smallTitleBottom.frame = CGRectMake(CGRectGetMaxX(line.frame) + 10, 29, ([UIScreen mainScreen].bounds.size.width ) / 2 - 55, 11);
    smallTitleBottom.adjustsFontSizeToFitWidth = YES;
    titleView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 90, 45);
    
    if (self = [super initWithFrame:titleView.frame]) {
        [self addSubview:titleView];
    }
    return self;
}



@end
